package light.head.dao.sys;

import java.util.List;

import light.head.enm.RESULT;
import light.head.framework.base.BaseDAO;
import light.head.model.OrganTypeRelation;

import org.springframework.stereotype.Service;
@Service
public class OrganTypeRelationDAO extends BaseDAO<OrganTypeRelation, Integer> {
	
	private static final String sql_findSonList = "FROM OrganTypeRelation ot WHERE ot.gfpCode = ?";
	private static final String sql_deleteByParentCode = "DELETE FROM OrganTypeRelation otr WHERE otr.gfpCode = ?";
	
	/**
	 * 根据机构类型编号获取相关的所有子机构类型
	 */
	public List<OrganTypeRelation> findSonList(Integer code) {
		if (null == code)
			return null;
		List<OrganTypeRelation> list = findI(sql_findSonList, code);
		return list;
	}
	
	/**
	 * 根据父类别编号删除所有子类别
	 * @param	父类别编号
	 */
	public RESULT deleteByParentCode(Integer code) {
		if (null == code)
			return RESULT.PARAMETER_ERROR;
		
		execute(sql_deleteByParentCode, code);
		return RESULT.SUCCESS;
	}
	
	
	
}
